package org.business.accounting.services;

import org.apache.tapestry5.ValueEncoder;
import org.business.accounting.interfaces.BasicOrder;
import org.business.accounting.service.OrderDAO;

public class OrderEncoder implements ValueEncoder {
	
	private OrderDAO orderDAO;
	
	public OrderEncoder(OrderDAO orderDAO) {
		this.orderDAO = orderDAO;
	}

	public String toClient(Object arg0) {
		return ((BasicOrder) arg0).getId() + "";
	}

	public Object toValue(String arg0) {
		return orderDAO.get(Long.parseLong(arg0));
	}

}
